# author destiny1
# Date: 2023/8/9 19:19
import time

def work1():
    while True:
        print('---work1---')
        #保存现场 让出CPU控制器
        yield
        time.sleep(0.5)

def work2():
    while True:
        print('---work2---')
        yield
        time.sleep(0.5)

if __name__ == '__main__':
    w1 = work1()
    w2 = work2()
    while True:
        next(w1)
        next(w2)